package com.example.mapper;

import com.example.pojo.ParseTeacher;
import org.apache.ibatis.annotations.*;
import org.yaml.snakeyaml.events.Event;

import java.util.ArrayList;
import java.util.Vector;

@Mapper
public interface TeacherMapper {
    /*
    * 查询所有老师
    * */
    @Select("select teacher.id,teacher.name,teacher.department,course.name as course  from teacher left join course on teacher.name=course.teacher order by id")
    Vector<ParseTeacher> select();

    /*
    * 条件查询
    * */
    Vector<ParseTeacher> selectTeacher(String name, String department, String id);
    /*
    * 修改老师
    * */
    @Update("update  teacher,course set teacher.name=#{name},teacher.department=#{department},course.name=#{course} where teacher.id=#{id}")
    void update(ParseTeacher parseTeacher);

    @Delete("delete from teacher where name=#{name}")
    void delete_1(String name);

    @Delete("delete from course where name=#{name}")
    void delete_2(String name);

    @Insert("insert into teacher (id, name, department) values (#{id},#{name},#{department})")
    void insertTeacher(ParseTeacher teacher);
    @Insert("insert into user_pass (id, passwd, authority) VALUE (#{id},'123456','1')")
    void insertPass(ParseTeacher teacher);

    @Select("select name from teacher;")
    ArrayList<String> selectTeachers();
}
